{include file="$header" /}
<div class="mk-app-warp">
    <mk-table
        url="catalog/index"
        save-url="catalog/save"
        update-url="catalog/update"
        delete-url="catalog/delete"
        synchro-url="catalog/synchro"
        copy-url="catalog/copyList"
        :copy-multiple="false"
        :date-search="false"
        :field="field"
        :scene="scene"
        tree>
    </mk-table>
</div>
{include file="$component" /}
<script>
    var field = [
        {
            prop: 'title', 
            label: '标题', 
            rules: {required: true},
        },
        {
            prop: 'id', 
            label: '编号(ID)', 
            width: '100px',
        },
        {
            prop: 'pid', 
            label: '父级', 
            type: 'select', 
            option: [], 
            self: true, 
            tree: true, 
            props:{label: 'title', value: 'id'}, 
            rules: {required: true},
            table: false,
        },
        {
            prop: 'show', 
            label: '显示', 
            type: 'select', 
            option: [
                {label: "不显示", value: 0},
                {label: "都显示", value: 1},
                {label: "头部显示", value: 2},
                {label: "底部显示", value: 3}
            ],
            default: 1,
            props: {label: 'label', value: 'value'}, 
            rules: {required: true},
            width: '150px',
        },
        {
            prop: 'type', 
            label: '类型', 
            type: 'select', 
            option: {:json_encode($option)},
            props: {label: 'title', value: 'name'}, 
            required: [{prop: 'links_type', value: 0}],
            form: [{prop: 'links_type', value: 0}],
            width: '150px',
        },
        {
            prop: 'seo_url', 
            label: '路由', 
            placeholder: '请不要输入中文',
            tips: '当类型为页面时，会自动生成模板文件',
            form: [{prop: 'links_type', value: 0}],
            required: [{prop: 'links_type', value: 0},{prop: 'type', value: 'page'}],
            update: 'index',
            rules:{pattern: /^[^\u4e00-\u9fa5]+$/, message: '不能包含中文'},
            width: '150px',
        },
        {
            prop: 'sort', 
            label: '排序', 
            default: 0,
            rules: {required: true},
            table: false,
        },
        {
            prop: 'num', 
            label: '标识', 
            width: '100px',
        },
        {
            prop: 'cover', 
            label: '封面', 
            type: 'image', 
            width: '60px',
            table: false
        },
        {
            prop: 'group_id', 
            label: '访问权限', 
            type: 'select', 
            option: tree.convertString({:json_encode($group)}),
            tree: true, 
            multiple: true,
            props:{label: 'title', value: 'id'}, 
            form: [{prop: 'links_type', value: 0}],
            default: [],
            table: false,
        },
        {
            prop: 'seo_title', 
            label: 'SEO标题', 
            table: false,
            form: [{prop: 'links_type', value: 0}],
        },
        {
            prop: 'seo_keywords', 
            label: 'SEO关键词', 
            table: false,
            form: [{prop: 'links_type', value: 0}],
        },
        {
            prop: 'seo_description',
            type: 'textarea', 
            label: 'SEO描述', 
            table: false,
            form: [{prop: 'links_type', value: 0}],
        },
        {
            prop: 'links_type', 
            label: '使用链接', 
            type: 'select', 
            option: [{label:'默认', value: 0,},{label:'指定',value: 1,}],
            props: {label: 'label', value: 'value'}, 
            default: 0,
            table: false,
        },
        {
            prop: 'links_value',
            label: '链接地址', 
            type: 'link', 
            form: [{prop: 'links_type', value: 1}],
            table: false,
        },
        {
            prop: 'mobile', 
            label: '手机显示',  
            type: 'switch', 
            default: 1,
            table: false
        },
        {
            prop: 'status', 
            label: '状态',  
            type: 'switch', 
            default: 1,
            width: '100px', 
        },
        {
            prop: 'content', 
            label: '详情', 
            type: 'editor',
            table: false, 
            form: [{prop: 'links_type', value: 0}],
        },
        {
            prop: 'field', 
            label: '', 
            type: 'field', 
            ifset: true,
            default: [], 
            table: false
        },
    ];
    new Vue({
        el: '#app',
        data() {
            return {
                scene: [
                    {
                        label: '基本信息', 
                        field: field.remove(['seo_title','seo_keywords','seo_description','field'])
                    },
                    {
                        label: 'TDK设置', 
                        field: field.only(['seo_title','seo_keywords','seo_description']), 
                        title: 'SEO优化<span class="tips">（非专业人员,请勿修改）</span>'
                    },
                    {
                        label: '自定义字段', 
                        field: field.only(['field']), 
                        title: '自定义字段<span class="tips">（非程序员,请勿修改）</span>'
                    },
                ]
            }
        },
    })
</script>
{include file="$footer" /}